package com.shoddon.cloud.ribbon;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class ComputeService {
	
	@Autowired
    RestTemplate restTemplate;
	
    @HystrixCommand(fallbackMethod = "addServiceFallback")//来指定回调方法
    public String addService() {
        return restTemplate.getForEntity("http://COMPUTE-SERVICE/compute?no1=10&no2=20", String.class).getBody();
    }
    
    public String addServiceFallback() {
        return "error";
    }
}
